package com.medical.goods.service.impl;

import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.Query;

import com.medical.goods.dao.SeckillSessionDao;
import com.medical.goods.entity.SeckillSessionEntity;
import com.medical.goods.service.SeckillSessionService;


@Service("seckillSessionService")
public class SeckillSessionServiceImpl extends ServiceImpl<SeckillSessionDao, SeckillSessionEntity> implements SeckillSessionService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SeckillSessionEntity> page = this.page(
                new Query<SeckillSessionEntity>().getPage(params),
                new QueryWrapper<SeckillSessionEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 批量查询场次
     * @param ids
     * @return
     */
    @Override
    public List<SeckillSessionEntity> findAll(List<String> ids) {
        List<String> collect = ids.stream().distinct().collect(Collectors.toList());
        List<SeckillSessionEntity> sessionEntities = baseMapper.selectBatchIds(collect);
        return sessionEntities;
    }

}